<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/3/22
  Time: 15:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>菜单管理</title>
    <script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>

    <script>

        function deleteById(id){

            if(confirm("是否删除？？？")){
                $.ajax({
                    url:'${pageContext.request.contextPath}/menu/delete/'+id,
                    dataType:'json',
                    success:function(data){
                        if(data.success){
                            <%--window.location.href='${pageContext.request.contextPath}/menu/list';--%>
                            window.location.href=window.location.href;
                        }else{
                            alert(data.msg);
                        }
                    }
                })
            }


        }


    </script>
</head>
<body>

<div style="padding:10px;background-color: skyblue;border-radius: 10px;box-shadow: 0 0 20px orange;margin: 30px">

    <a href="${pageContext.request.contextPath}/menu/toAdd">添加</a>
</div>

<table cellspacing="0" cellpadding="0" border="1" width="100%">

    <tr>
        <td>序号</td>
        <td>menuName</td>
        <td>上级ID</td>
        <td>url</td>
        <td>menuType</td>
        <td>active</td>
        <td>createtime</td>
        <td>操作</td>
    </tr>
<c:forEach items="${list}" varStatus="status" var="menu">
    <tr>
        <td>${status.count}</td>
        <td>${menu.menuName}</td>
        <td>${menu.parentId}</td>
        <td>${menu.url}</td>
        <td>${menu.menuType}</td>
        <td>${menu.active}</td>
        <td>
            <fmt:formatDate value="${menu.createtime}" pattern="yyyy-MM-dd HH:mm:ss"/>
        </td>
        <td>
            <a href="${pageContext.request.contextPath}/menu/toEdit/${menu.menuId}">修改</a>

            <button onclick="deleteById(${menu.menuId})">删除</button>
        </td>
    </tr>
</c:forEach>




</table>






</body>
</html>
